<template>
	<view class="main" v-if="JSON.stringify(props.data) != '{}'">
		<view class="left" :style="{'margin-top' : props.type == 4 ? '50rpx': ''}">
			<image :src="props.data.img ?'https://ddzj.hihink.com' + props.data.img : '../static/test.png'"
				mode="aspectFill"></image>
		</view>
		<view class="right">
			<view class="right-top">
				<view class="title">{{props.data.z_name ? props.data.z_name : '暂无'}}</view>
				<view class="person" v-if="props.type == 1">
					<text>学员人数</text>
					<text>99+</text>
				</view>
				<view class="person" v-if="props.type == 2 || props.type == 5" @click="handleDelete">

					<u-icon name="trash" color="#d64a42" size="28"></u-icon>
				</view>
			</view>
			<view class="right-middle">当前评级：{{props.data.Level.title}}</view>
			<view class="right-middle">
				{{props.data.z_introduce ? props.data.z_introduce  : '暂无'}}
			</view>
			<view class="right-bottom" v-if="props.type == 1">
				<view class="left"> </view>
				<view class="right">选择TA</view>
			</view>
			<view class="right-bottom" v-if="props.type == 3">
				<view class="left"> </view>
				<view class="right" style="background-color: #4575f5; color: #fff;">选择TA</view>
			</view>
			<view class="right-bottom" v-if="props.type == 2">
				<view class="right-detail" @click="handleSkipDetai">助教详情</view>
				<view class="left-detail" @click="changeAssistant">替换助教</view>
			</view>
			<view class="right-bottom" v-if="props.type == 4">
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { postHttpsRequset } from '../public-ts-file/request';
	const props = defineProps({
		type: Number,
		data: Object
	})

	// 跳转替换助教
	const changeAssistant = () => {
		uni.navigateTo({
			url: '/pages/home/mine/platformAssistant'
		})
	}

	// 跳转助教详情
	const handleSkipDetai = () => {
		uni.navigateTo({
			url: '/pages/home/school/studentDetail?type=2'
		})
	}

	// 删除
	const emit = defineEmits(['deleteAssistant'])
	const handleDelete = () => {
		const parms = {
			path: '/shop/Zhujiao/del_zhu',
			methods: 'post',
			data: {
				id: props.data.id
			}
		}
		uni.showModal({
			title: '删除',
			content: '确定删除吗？',
			success: async (res) => {
				if (res.confirm) {
					const resposne = await postHttpsRequset(parms)
					if (resposne.code == 200) {
						emit('deleteAssistant', true)
						uni.showToast({
							title: '删除成功',
							icon: 'none'
						})
					} else {
						uni.showToast({
							title: '删除失败',
							icon: 'none'
						})
					}
				}
			}
		})

	}
</script>

<style lang="scss" scoped>
	.main {
		padding: 0 28rpx;
		margin-bottom: 28rpx;
		display: flex;
		// justify-content: space-between;
		align-items: center;
		box-shadow: rgba(0, 0, 0, 0.08) 0px 4px 12px;
		border-radius: 20rpx;

		.left {
			margin-right: 15rpx;
			flex: 1;

			image {
				width: 142rpx;
				height: 200rpx;
				border-radius: 10rpx;
				margin-bottom: 40rpx;
			}
		}

		.right {
			flex: 4;

			.right-top {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.person {
					text {
						opacity: 1;
						/** 文本1 */
						font-size: 8px;
						font-weight: 400;
						letter-spacing: 0px;
						line-height: 10.98px;
						color: rgba(170, 170, 170, 1);

					}

					text:nth-child(2) {
						color: rgba(51, 119, 254, 1);
						padding-left: 5rpx;
					}
				}

				.title {
					opacity: 1;
					/** 文本1 */
					font-size: 12px;
					font-weight: 400;
					letter-spacing: 0px;
					line-height: 16.46px;
					color: rgba(51, 51, 51, 1);
				}
			}

			.right-middle {
				opacity: 1;
				/** 文本1 */
				font-size: 8px;
				font-weight: 400;
				letter-spacing: 0px;
				line-height: 10.98px;
				color: rgba(170, 170, 170, 1);
				padding: 5px 0 5rpx 0;
			}

			.right-bottom {
				display: flex;
				// justify-content: space-between
				justify-content: flex-end;
				padding-top: 14rpx;
				align-items: center;

				.left {
					opacity: 1;
					/** 文本1 */
					font-size: 8px;
					font-weight: 400;
					letter-spacing: 0px;
					line-height: 10.98px;
					color: rgba(170, 170, 170, 1);
					flex: 8;
					display: flex;
					align-items: flex-end;
				}

				.left-detail {
					margin-left: 10rpx;
					padding: 10rpx 40rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #5a80f7;
					/** 文本1 */
					font-size: 10px;
					line-height: 14.48px;
					color: #fff;
					border-radius: 30rpx;
				}

				.right-detail {
					padding: 10rpx 40rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					border: 1rpx solid #5a80f7;
					/** 文本1 */
					font-size: 10px;
					line-height: 14.48px;
					color: rgba(51, 119, 254, 1);
					border-radius: 30rpx;
				}

				.right {
					padding: 10rpx 40rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					border: 1rpx solid #5a80f7;
					opacity: 1;
					/** 文本1 */
					font-size: 10px;
					font-weight: 400;
					letter-spacing: 0px;
					line-height: 14.48px;
					color: rgba(51, 119, 254, 1);
					border-radius: 30rpx;
				}
			}
		}
	}
</style>